package cn.francis.chatplatform.modules.session.mapper;

import cn.francis.chatplatform.modules.session.po.ChatSession;
import cn.francis.chatplatform.modules.session.vo.TestVO;
import cn.francis.chatplatform.modules.session.vo.TestVO3;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import jakarta.validation.constraints.Pattern;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author 张俊辉
 */

public interface ChatSessionMapper extends BaseMapper<ChatSession> {
    /**
     * 测试 choose 标签
     * @param num 随机数
     * @return 会话对象
     */
    ChatSession selectTest(@Param("num") String num);
    @Select("""
        <script>
            select * from td_chat_session where
            <choose>
                <when test = 'test.test == "N"'>
                    id = 1
                </when>
                <when test = 'test.test == "Y"'>
                    id = 2
                </when>
            </choose>

        </script>
    """)
    ChatSession selectTest3(@Param("test") TestVO testVO);
    @Select("""
        <script>
            select * from td_chat_session
            <where>
                <choose>
                    <when test='"N".equals(vo.flag)'>
                        id = 1
                    </when>
                    <when test='vo.flag.equals("Y")'>
                        id = 2
                    </when>
                </choose>
            </where>
        </script>
    """)
    ChatSession selectTest4(@Param("vo") TestVO3 testVO);
}




